﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace Doo.Controls
{
    public abstract class DataField
    {
        /// <summary>
        /// 作为标题时的文字
        /// </summary>
        public string HeaderText
        { get; set; }

        /// <summary>
        /// 标题标签属性，将放在th标签内
        /// </summary>
        public string HeaderAttrs { get; set; }

        /// <summary>
        /// 生成的模板
        /// </summary>
        public abstract string ToTemplate();

        public virtual string ToHeader()
        {
            string h = HeaderAttrs ?? "";
            if (MoveHandler) h += " moveHandler='yes'";
            return h;
        }

        /// <summary>
        /// 是否作为移动
        /// </summary>
        public bool MoveHandler { get; set; }

        /// <summary>
        /// 列样式
        /// </summary>
        public string CssClass { get; set; }

        /// <summary>
        /// 对于本列的表格底部
        /// </summary>
        public string FooterText { get; set; }
    }

    /// <summary>
    /// 数据字段
    /// </summary>
    public class BoundField : DataField
    {
        /// <summary>
        /// 对应的数据字段，格式为field,format
        /// </summary>
        public string DataField
        { get; set; }

        public override string ToTemplate()
        {
            return string.Format("{{#{0}}}", this.DataField);
        }
    }

    public class TemplateField : DataField
    {
        public string Template { get; set; }

        public override string ToTemplate()
        {
            return this.Template;
        }
    }
}
